import logo from './logo.svg';
import './App.css';
import React, { useCallback, useEffect, useState } from 'react';
import { click } from '@testing-library/user-event/dist/click';
import { useMemo,useRef} from 'react';


function App(){

  const inputRef=useRef(null)
  console.log('inputRef',inputRef);// 这将打印出ref对象，但current属性可能还是null  
  
  useEffect(()=>{
    console.log('inputRef useEffect中执行的',inputRef);
    inputRef.current.focus()
  })




   return (
    <div>
      <input ref={inputRef} type='text'/>
      <button onClick={()=>inputRef.current.focus()}> focus input</button>
    </div>
   )
}

export default App;
